using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_LabTestMap : EntityTypeConfiguration<SO_LabTest>
    {
        public SO_LabTestMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Request__, t.Code, t.Done });

            // Properties
            this.Property(t => t.Patient__)
                .HasMaxLength(6);

            this.Property(t => t.Patient_Name)
                .HasMaxLength(50);

            this.Property(t => t.Request__)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Diagnosis)
                .HasMaxLength(30);

            this.Property(t => t.Test)
                .HasMaxLength(50);

            this.Property(t => t.Result_Name)
                .HasMaxLength(50);

            this.Property(t => t.Value)
                .HasMaxLength(20);

            this.Property(t => t.Unit)
                .HasMaxLength(15);

            this.Property(t => t.Code)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.Physician)
                .HasMaxLength(35);

            this.Property(t => t.Examiner)
                .HasMaxLength(35);

            this.Property(t => t.Done)
                .IsRequired()
                .HasMaxLength(3);

            this.Property(t => t.GENDER)
                .HasMaxLength(7);

            this.Property(t => t.Address)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("SO_LabTest");
            this.Property(t => t.Patient__).HasColumnName("Patient_#");
            this.Property(t => t.Patient_Name).HasColumnName("Patient_Name");
            this.Property(t => t.Request__).HasColumnName("Request_#");
            this.Property(t => t.Diagnosis).HasColumnName("Diagnosis");
            this.Property(t => t.Test__).HasColumnName("Test_#");
            this.Property(t => t.Test).HasColumnName("Test");
            this.Property(t => t.Result_Name).HasColumnName("Result_Name");
            this.Property(t => t.Value).HasColumnName("Value");
            this.Property(t => t.Unit).HasColumnName("Unit");
            this.Property(t => t.Request_date).HasColumnName("Request_date");
            this.Property(t => t.Code).HasColumnName("Code");
            this.Property(t => t.Physician).HasColumnName("Physician");
            this.Property(t => t.Examiner).HasColumnName("Examiner");
            this.Property(t => t.Done).HasColumnName("Done");
            this.Property(t => t.GENDER).HasColumnName("GENDER");
            this.Property(t => t.Birth_Date).HasColumnName("Birth_Date");
            this.Property(t => t.Address).HasColumnName("Address");
        }
    }
}
